//
//  LevelSets.m
//  TestUsingCocos2dAndCocosBuilder
//
//  Created by Ronald Ram on 1/3/13.
//  Copyright 2013 Ronald Ram. All rights reserved.
//

#import "LevelSets.h"
#import "SceneMgr.h"
#import "MenuMgr.h"


#import "MainMenu.h"
#import "LevelSet_01.h"

#import "CCBReader.h"
#import "CCControlButton.h"


@interface LevelSets()

- (void) debugData;
- (void) startUpData;
- (void)didLoadFromCCB;

@end



@implementation LevelSets

/*
- (id) init
{
    if ( self = [super init] ) [self startUpData];
    return self;
}
*/


- (void) onPress: (id) sender
{
    CCControlButton *button = (CCControlButton *) sender;
    CCLayer *layer = nil;
    
//    switch (sender.tag)
    switch (button.tag)
    {
        case LS_ONE:
//            [ [SceneMgr sharedScene] switchLayer: [LevelSet_01 node] ];
            layer = (CCLayer *) [CCBReader nodeGraphFromFile: @"LevelSet1.ccbi"];
            [[SceneMgr sharedScene] switchLayer: layer];
            break;
        case MAIN_MENU:
//            [ [SceneMgr sharedScene] switchLayer: [MainMenu node] ];
            layer = (CCLayer *) [CCBReader nodeGraphFromFile: @"MainMenu.ccbi"];
            [[SceneMgr sharedScene] switchLayer: layer];
            break;
    }
}


#pragma mark Private-Methods
- (void) startUpData
{
//    CCLayer *layer = (CCLayer *) [CCBReader nodeGraphFromFile: @"LevelSets.ccbi"];
//    [self addChild: layer];
    
    self.tag = LEVEL_SETS;
}

- (void)didLoadFromCCB
{
    [self startUpData];
}

- (void) debugData
{
    CGSize size = [CCDirector sharedDirector].winSize;
    
    //add BG to menu
    CCLayerColor *bg = [CCLayerColor layerWithColor:ccc4(0, 128, 255, 255)];
    [self addChild: bg];
    
    //add menu title
    CCLabelTTF *label = [CCLabelTTF labelWithString: @"Level Sets" fontName: @"Noteworthy" fontSize: 56];
    label.position = ccp(size.width / 2, size.height - (size.height * 0.15) );
    [self addChild: label];
    
    //add MenuItem btns
    CCMenuItemFont *item1 = [CCMenuItemFont itemWithString:@"LevelSet 1" target:self selector:@selector(onPress:)];
    item1.tag = LS_ONE;
    
    CCMenuItemFont *item2 = [CCMenuItemFont itemWithString:@"Back" target:self selector:@selector(onPress:)];
    item2.tag = MAIN_MENU;
    
    //add menuItem(s) to menu
    CCMenu *menu = [CCMenu menuWithItems:item1, item2, nil];
    [menu alignItemsVerticallyWithPadding: 30];
    [menu setColor: ccORANGE];
    
    //add menu to layer
    [self addChild: menu];
    self.tag = LEVEL_SETS;
}

@end
